package com.myspace.service.impl.post;

import com.myspace.mapper.PostMapper;
import com.myspace.pojo.Post;
import com.myspace.service.space.post.AddPostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Service
public class AddPostServiceImpl implements AddPostService {

    @Autowired
    private PostMapper postMapper;

    @Override
    public Map<String, String> addpost(Integer userId, String content) {
        Date now = new Date();
        Post post = new Post(null, userId, content, now);
        postMapper.insert(post);

        Map<String, String> map = new HashMap<>();
        map.put("error_message", "success");
        map.put("id", post.getId().toString());

        return map;
    }
}
